# -*- coding: utf-8 -*-
from django.db.models import Avg, Max, Min, Count, Sum  # 引入函数

from app import models


# 计算所有图书的平均价格:
def avgData(requests):
    res = models.BookData.objects.aggregate(Avg("price"))
    print(res, type(res))


# 计算所有图书的数量、最贵价格和最便宜价格:

def countData(requests):
    res = models.Book.objects.aggregate(c=Count("id"), max=Max("price"), min=Min("price"))
    print(res, type(res))
